﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using BaMusaSoft.RPS.ViewModel.HelperClasses;
namespace BaMusaSoft.RPS.View.Converters
{
    public class DateMaskConveter: IValueConverter
    {
    
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                string s = (string)value;
                if (s == "")
                {
                    return value;
                }
                return Helper.PutMask(s);
            }

            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                //string enteredDate = (string)value;
                //string resultDate;
                ////if (enteredDate == "")
                ////{
                ////    return enteredDate;
                ////}
                ////string unmaskedDate = Helper.UnmaskDate(enteredDate);
                ////if (Helper.IsValidDate(unmaskedDate))
                ////{
                ////    return unmaskedDate;
                ////}
                ////else
                ////{
                ////    throw new ArgumentException("Date is not valid");
                ////}
                //if (Helper.TryUnmaskDate(enteredDate, out resultDate))
                //{
                //    return resultDate;
                //}
                //return enteredDate;
                throw new NotSupportedException();

        }
    }
}
